using System;
using UnityEngine;

[Serializable]
public class DragObject : MonoBehaviour
{
	public GameObject @object;

	private Transform oT;

	private bool selected;

	public void Awake()
	{
		if ((bool)@object)
		{
			oT = @object.transform;
			return;
		}
		DragObject dragObject = ((DragObject)GetComponent(typeof(DragObject))) as DragObject;
		dragObject.enabled = false;
	}

	public void FixedUpdate()
	{
		if (!@object)
		{
			return;
		}
		Camera main = Camera.main;
		int i = 0;
		Touch[] touches = Input.touches;
		for (int length = touches.Length; i < length; i++)
		{
			Ray ray = main.ScreenPointToRay(touches[i].position);
			RaycastHit hitInfo = default(RaycastHit);
			if (touches[i].phase == TouchPhase.Began)
			{
				if (Physics.Raycast(ray, out hitInfo, 100f) && hitInfo.collider.gameObject == @object)
				{
					selected = true;
				}
			}
			else if (touches[i].phase == TouchPhase.Moved)
			{
				if (selected)
				{
					Vector3 vector = main.transform.InverseTransformPoint(0f, 0f, 0f);
					Camera camera = main;
					Vector2 position = touches[i].position;
					float x = position.x;
					Vector2 position2 = touches[i].position;
					Vector3 vector2 = camera.ScreenToWorldPoint(new Vector3(x, position2.y, vector.z));
					float x2 = vector2.x;
					Vector3 position3 = oT.position;
					position3.x = x2;
					Vector3 vector4 = oT.position = position3;
				}
			}
			else if (touches[i].phase == TouchPhase.Ended)
			{
				selected = false;
			}
		}
	}

	public void Main()
	{
	}
}
